﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GKS.DataTypes.Trees {
    /// <summary>
    /// A class that implements the nodes of a tree.
    /// </summary>
    /// <typeparam name="K">The key of the node.</typeparam>
    /// <typeparam name="V">The value of the node.</typeparam>
    public class TreeNode<K, V> where K:IComparable<K>, new() {
        #region parameters
        ///// <summary>
        ///// GET or SET the key of the node.
        ///// </summary>
        //public K Key { get; set; }

        ///// <summary>
        ///// GET or SET the value of the node.
        ///// </summary>
        //public V Value { get; set; }

        /// <summary>
        /// GET or SET the element of this node
        /// </summary>
        public KeyValuePair<K, V> Element { get; set; }

        /// <summary>
        /// GET the children of this node.
        /// </summary>
        public List<TreeNode<K, V>> Children { get; set; }

        /// <summary>
        /// The parent of this node.
        /// </summary>
        public TreeNode<K, V> Parent { get; set; }
        #endregion

        #region constructors
        ///// <summary>
        ///// A constructor that does nothing. The values of the parameters must be set manually.
        ///// </summary>
        //public TreeNode() { }

        /// <summary>
        /// A constructor of a TreeNode instance.
        /// </summary>
        /// <param name="key">The key of the node.</param>
        /// <param name="val">The value (element) of the node.</param>
        public TreeNode(K key, V val) : this(new KeyValuePair<K, V>(key, val)) { }
        public TreeNode(KeyValuePair<K, V> element) : this(element, null) { }

        /// <summary>
        /// A constructor of a TreeNode instance.
        /// </summary>
        /// <param name="key">The key of the node.</param>
        /// <param name="val">The value of the node.</param>
        /// <param name="parent">The parent of the node.</param>
        public TreeNode(K key, V val, TreeNode<K, V> parent) : this(new KeyValuePair<K, V>(key, val), parent) { }
        public TreeNode(KeyValuePair<K, V> element, TreeNode<K, V> parent) : this(element, new List<TreeNode<K, V>>(), parent) { }

        /// <summary>
        /// A constructor of a TreeNode instance.
        /// </summary>
        /// <param name="key">The key of the node.</param>
        /// <param name="val">The value of the node.</param>
        /// <param name="children">The children of the node.</param>
        /// <param name="parent">The parent of the node.</param>
        public TreeNode(K key, V val, List<TreeNode<K, V>> children, TreeNode<K, V> parent) : this(new KeyValuePair<K, V>(key, val), children, parent) { }
        public TreeNode(KeyValuePair<K, V> element, List<TreeNode<K, V>> children, TreeNode<K, V> parent) {
            Element = element;
            Children = children;
            Parent = parent;
        }
        #endregion

        #region methods

        #endregion
    }
}
